<script type="text/javascript" src="../js/jquery-easyui-1.3.5/jquery.min.js" charset="UTF-8"></script>
 <script type="text/javascript" src="../js/jquery-easyui-1.3.5/jquery.easyui.min.js" charset="UTF-8"></script>
 <link rel="stylesheet" href="../js/jquery-easyui-1.3.5/themes/default/easyui.css" type="text/css" />
 <link rel="stylesheet" href="../js/jquery-easyui-1.3.5/themes/icon.css" type="text/css" />
 <link rel="stylesheet" href="../css/main.css" type="text/css" />
 <script type="text/javascript" src="../js/mine.js"></script>
 <script type="text/javascript" src="../js/jquery-easyui-1.3.5/locale/easyui-lang-zh_CN.js" charset="UTF-8"></script>
 <script type="text/javascript" src="../js/validate.js" charset="UTF-8"></script> 	 
<script type="text/javascript" charset="UTF-8">
	var notMStudentDatagrid;
	var notMStudentLayout;
	var notMStudentForm;
	var sexData = [{
		"id":"male",
		"text":"男"
	},{
		"id":"female",
		"text":"女",
	}];
	
	$(function(){
		notMStudentForm = $('#notMStudentForm').form();
		notMStudentLayout = $('#notMStudentLayout').layout();
		notMStudentDatagrid = $('#notMStudentDatagrid').datagrid({
		url:'../servlet/GetNMStudentServlet',
		//title:'学生信息',
		//iconCls:'icon-save',
		fitColumns:true,
		nowrap:false,
		//striped:true,
		idField:'sno',
		pagination:true,
		pageSize:10,
		pageList:[10,20,30],
		fit:true,
		border:false,
		sortName:'sno',
		sortOrder:'desc',
		//showFooter:true,
		columns:[[{
			field:'cut',
			checkbox:true
		},{
			title:'学号',
			field:'sno',
			width:100,
			sortable:true
		},{
			title:'姓名',
			field:'sname',
			width:100,
			sortable:true
		},{
			title:'性别',
			field:'sex',
			width:100,
			sortable:true,
			formatter:function(value,rowData,rowIndex){
					 for(var i=0; i<sexData.length; i++){  
			                if (sexData[i].id == value) {
			                	return sexData[i].text;  
			                }
		            }  
				}
		},{
			title:'专业',
			field:'major',
			width:100
		},{
			title:'年级',
			field:'grade',
			width:100
		},{
			title:'分工',
			field:'stype',
			width:100
		},{
			title:'参与项目数',
			field:'proNum',
			width:100,
			formatter: function(value,rowData,rowIndex){
				if(value != 0) {
	            	return '<a href="#" onclick="showProject(' + rowIndex + ');">' + value + '</a>';
				} else {
					return value;
				}
	     	}  
		}]],
		toolbar:[{
			text:'管理',
			iconCls:'icon-add',
			handler:function(){
				var rows = notMStudentDatagrid.datagrid('getSelections');
				var ids = [];
				console.info(rows.length);
				if(rows.length > 0) {
					$.messager.confirm('提示','确定要管理所选择的学生吗?',function(b) {
							if(b) {
								for(var i=0;i<rows.length; i++) {
									ids.push(rows[i].sno);
								}
								console.info(ids);
								$.ajax({
									url:'../servlet/ManageStudentServlet',
									data:{
										ids:ids.join(',')//用,分隔
									},
									type:'post',
									dataType:'json',
									success:function(r) {
										if(r && r.success) {
											notMStudentDatagrid.datagrid('acceptChanges');
											notMStudentDatagrid.datagrid('load');
											notMStudentDatagrid.datagrid('unselectAll');
											notMStudentDatagrid.datagrid('rejectChanges');
											//console.info(notMStudentDatagrid.datagrid('getSelections'));
											$.messager.show({
												title:'提示',
												msg:r.msg
											});
										} else {
											$.messager.alert('提示','增加管理学生失败.','error');
										}
									}
								});
							}
					});
				} else {
					$.messager.alert('提示','未选择任何数据.','warning');
				} 
			}
		},'-',{
			text:'取消',
			iconCls:'icon-undo',
			handler:function(){
				notMStudentDatagrid.datagrid('unselectAll');
				notMStudentDatagrid.datagrid('rejectChanges');
			}
		},'-',{
			text:'刷新',
			iconCls:'icon-reload',
			handler:function(){
				notMStudentDatagrid.datagrid('unselectAll');
				notMStudentDatagrid.datagrid('rejectChanges');
				notMStudentDatagrid.datagrid('load');
			}
		},'-']
	});
	
		$('#stype').combobox({
			data:[{
				"id":"all",
				"text":"全部",
			},{
				"id":"美工",
				"text":"美工"
			},{
				"id":"前端",
				"text":"前端",
			},{
				"id":"后台",
				"text":"后台"
			}],
			valueField:'id',
			textField:'text',
			delay:1000
		});
		
		$('#sex').combobox({
			data:[{
				"id":"all",
				"text":"全部",
			},{
				"id":"male",
				"text":"男"
			},{
				"id":"female",
				"text":"女",
			}],
			valueField:'id',
			textField:'text',
			editable:false
	});
});
	
showProject = function(i) {
	var rows = notMStudentDatagrid.datagrid('getRows');
	console.info(i);
	console.info(rows);
	var title = '参与项目_' + rows[i].sname;
	console.info(title);
	showProjectDialog = parent.$('#showProjectDialog', parent.document).dialog({
		title:title,
		modal:true,
		method:'post',
		collapsible:false,
		showHeader:false,
		width:500,
		height:500,
		href:'teacher/showProjectData.jsp?sno=' + rows[i].sno
	});
	
	showProjectDialog.dialog('open');
}
	
searchStudent = function() {
	console.info(serializeObject(notMStudentForm));
	notMStudentDatagrid.datagrid('load',serializeObject(notMStudentForm));
}

cleanStudent = function() {
	notMStudentDatagrid.datagrid('load',{});
	notMStudentForm.find('input').val('');
}
</script>



<div id="notMStudentLayout" fit="true" border="false" >
		<div region="north" border="false" split="false" title="查询" style="margin:0 auto;height:81px;" >
			<form id="notMStudentForm" class="datagrid-toolbar"  style="margin:0 auto;">
				<table>
					<tr>
						<td><b>学号</b><input type="text" name="sno" class="easyui-validatebox"  placeholder="您只能输入数字" data-options="validType:'nums'" /></td>
						<td><b>姓名</b><input type="text" name="sname"/></td>
						<td><b>性别</b><input type="text" name="sex" id="sex"/></td>
					</tr>
					<tr>
						<td><b>专业</b><input type="text" name="major" /></td>
						<td><b>年级</b><input type="text" name="grade" class="easyui-validatebox" placeholder="您只能输入4位数字" data-options="validType:'grade[4]'" /></td>
						<td>
							<b>分工</b><input type="text" name="stype" id="stype" />
						</td>
						<td>
							<a href="javascript:void(0);" class="easyui-linkbutton"  iconCls="icon-search" pain="false" onclick="searchStudent();" ></a>
						</td>
						<td>	
							<a href="javascript:void(0);" class="easyui-linkbutton"  pain="false" onclick="cleanStudent();" >清空</a>
						</td>
						
					</tr>
				</table>
			</form>
		</div>
	<div region="center" border="false">
		<table id="notMStudentDatagrid" fit="true" ></table>
	</div>	
</div>

